package com.tender.request;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

@Data
public class UserRequest {

    @NotBlank(message = "用户名不能为空")
    private String username;

    @NotBlank(message = "手机号码不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码不符合规范")
    private String phoneNo;

    @NotBlank(message = "身份证号码不能为空")
    @Pattern(regexp = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])\\d{3}[\\dxX]$", message = "身份证号码不符合规范")
    private String idNo;

    public static void main(String[] args) {
        UserRequest userRequest = new UserRequest();
        userRequest.setUsername("bruce");
        userRequest.setIdNo("32098119910908571X");
        userRequest.setPhoneNo("1325971664");
        // {"idNo":"32098119910908571X","phoneNo":"1325971664","username":"bruce"}
        System.out.println(JSON.toJSONString(userRequest));
    }

}
